<#include "/java_copyright.include">
<#assign className = table.className>   
<#assign classNameLower = className?uncap_first> 
package ${basepackage}.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.shinsoft.service.${className}Service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.shinsoft.dao.${className}Mapper;
import com.shinsoft.exception.entity.BussinessException;

import org.springframework.stereotype.Service;
import org.springframework.dao.DataAccessException;

import com.shinsoft.pojo.${className};


@Service("${classNameLower}Service")
public class ${className}ServiceImpl implements ${className}Service{

	@Autowired
	private ${className}Mapper ${classNameLower}Dao;
	
	private static final Logger LOG = LoggerFactory.getLogger(${className}ServiceImpl.class);
	
	@Override
	public List<${className}> get${className}s(){
		List<${className}> ${classNameLower}s;
		try{
			${classNameLower}s = ${classNameLower}Dao.getList();
		}catch(Exception e){
			LOG.error("查询${className}列表失败: ",e);
			throw new BussinessException("查询${className}列表失败");
		}
		return ${classNameLower}s;
	}
	
	@Override
	public ${className} getById(Serializable id){
		${className} ${classNameLower};
		try{
			${classNameLower} = ${classNameLower}Dao.getById(id);
		}catch(Exception e){
			LOG.error("查询${className}对象失败: ",e);
			throw new BussinessException("查询${className}对象失败");
		}
		return ${classNameLower};
	}
	
	@Override
	public void delete(Serializable id){
		try{
			${classNameLower}Dao.delete(id);
		}catch(Exception e){
			LOG.error("查询${className}对象失败: ",e);
			throw new BussinessException("删除${className}对象失败");
		}
	}
	
	@Override
	public void update(${className} ${classNameLower}){
		try{
			${classNameLower}Dao.update(${classNameLower});
		}catch(Exception e){
			LOG.error("更新${className}对象失败: ",e);
			throw new BussinessException("更新${className}对象失败");
		}
	}
	
	@Override
	public void save(${className} ${classNameLower}){
		try{
			${classNameLower}Dao.save(${classNameLower});
		}catch(DataAccessException e){
			throw new BussinessException("保存${className}对象失败: "+ e.getMessage());
		}
	}
	
	@Override
	public void batchSave(List<${className}> ${classNameLower}s){
		try{
			${classNameLower}Dao.insert(${classNameLower}s);
		}catch(DataAccessException e){
			throw new BussinessException("批量保存${className}对象失败: "+ e.getMessage());
		}
	}
	
}
